<?php

declare(strict_types=1);

namespace request;

use Exception;

/**
 * 请求异常
 */
class RequestException extends Exception
{
	protected $url = '';

	public function __construct($ch)
	{
		$info = curl_getinfo($ch);
		$this->url = $info['url'] ?? null;
		parent::__construct('Request URL:' . $this->url . ' Failed. ' . curl_error($ch), $info['http_code'] ?? 0);
	}

	public function getUrl()
	{
		return $this->url;
	}
}
